import 'package:flutter/material.dart';

void main() {
  runApp(const MaterialApp(
    debugShowCheckedModeBanner: false,
    home: HomePage(),
  ));
}

class HomePage extends StatelessWidget {
  const HomePage({super.key});

  void openDialog(BuildContext context) {
    showModalBottomSheet(
        context: context,
        builder: (context) {
          return SizedBox(
            height: 220,
            child: Column(
              children: [
                ListTile(
                  title: const Text("点赞"),
                  onTap: () {
                    print("点赞");
                    Navigator.pop(context);
                  },
                ),
                const Divider(),
                ListTile(
                  title: const Text("转发"),
                  onTap: () {
                    print("转发");
                    Navigator.pop(context);
                  },
                ),
                const Divider(),
                ListTile(
                  title: const Text("收藏"),
                  onTap: () {
                    print("收藏");
                    Navigator.pop(context);
                  },
                ),
              ],
            ),
          );
        });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("Alert"),
      ),
      body: Center(
        child: ElevatedButton(
            onPressed: () {
              openDialog(context);
            },
            child: const Text("打开showModalBottomSheet")),
      ),
    );
  }
}
